package com.lz.gmall.user.biz.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.lz.gmall.cart.vo.UserAuthInfoVo;
import com.lz.gmall.common.utils.UserAuthUtil;
import com.lz.gmall.user.biz.UserAddressBizService;
import com.lz.gmall.user.entity.UserAddress;
import com.lz.gmall.user.mapper.UserAddressMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 郭运龙
 */
@Service
public class UserAddressBizServiceImpl implements UserAddressBizService {

    @Autowired
    private UserAddressMapper userAddressMapper;

    /**
     * 获取到用户的订单地址
     * @return
     */
    @Override
    public List<UserAddress> getAllUserAddress() {
        //获取用户id
        UserAuthInfoVo userAuthInfo = UserAuthUtil.getUserAuthInfo();
        String userId = userAuthInfo.getUserId();
        LambdaQueryWrapper<UserAddress> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UserAddress::getUserId,userId);
        return userAddressMapper.selectList(wrapper);
    }
}
